const Sequelize = require('sequelize');
module.exports = function (sequelize, DataTypes) {
  return sequelize.define('m_tenant_fees', {
    id: {
      autoIncrement: true,
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: 'auto id'
    },
    uid: {
      type: DataTypes.BLOB,
      allowNull: true,
      defaultValue: Sequelize.Sequelize.literal('uuid_to_bin(uuid(),1)'),
      comment: 'uid'
    },
    tenant_id: {
      type: DataTypes.BIGINT,
      allowNull: true,
      defaultValue: 0,
      comment: '租户id'
    },
    payment_method: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '支付方式 wechat alipay 等'
    },
    payment_num: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '支付流水号'
    },
    payment_content: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '支付内容'
    },
    payment_money: {
      type: DataTypes.DECIMAL(12, 2),
      allowNull: true,
      comment: '支付金额'
    },
    start_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: '有效期开始时间'
    },
    expire_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: '有期过期时间'
    },
    history: {
      type: DataTypes.JSON,
      allowNull: true,
      comment: '历史'
    },
    create_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: '创建时间'
    },
    create_user_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: '创建人id'
    },
    create_user_name: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '创建人名'
    },
    modify_time: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: '修改时间'
    },
    modify_user_id: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: '修改人id'
    },
    modify_user_name: {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '修改人名'
    }
  }, {
    sequelize,
    tableName: 'm_tenant_fees',
    timestamps: false,
    freezeTableName: true,
    indexes: [
      {
        name: 'PRIMARY',
        unique: true,
        using: 'BTREE',
        fields: [
          { name: 'id' }
        ]
      },
      {
        name: 'idx_tenant_id',
        using: 'BTREE',
        fields: [
          { name: 'tenant_id' }
        ]
      },
      {
        name: 'idx_uide',
        using: 'BTREE',
        fields: [
          { name: 'uid' }
        ]
      }
    ]
  });
};
